document.addEventListener("DOMContentLoaded", function(){
	document.getElementById("comment").addEventListener("click", function(){
		console.log($("#contents").val());
		
		$.post("message!addMessage.action",{"message.content":$("#contents").val(),"goodId":$("#goodsids").val()},function(data,status){
       
			if(data==1)
				{
				
				 var $img=$("<img src=\"./img/head.jpg\">");
				 var $span=$("<span class=\"respond_btn\">回复</span>");
				 var $div0=$("<div><div>");
				 var $p1=$("<p></p>");
				 var $p2=$("<p></p>");
				 var username=$("#username").val();
				 $p1.html(username+":"+$("#contents").val());
				 var date=new Date();
				 var year=date.getFullYear();
				 var month=date.getMonth()+1;
				 var day=date.getDate();
				 var hour=date.getHours();
				 var minute=date.getMinutes();
				 var second=date.getSeconds();
				 var newdate=year+'-'+month+'-'+day+' '+hour+':'+minute+':'+second;
				 $p2.html(newdate);
				 $div0.append($p1);
				 $div0.append($p2);
				 
				 var $div=$("<div class=\"message_item\"></div>");
				$div.append($img);
				$div.append($span);
				$div.append($div0);
				 $("#allmessage").prepend($div);
				 document.getElementById("contents").value="";
				 
				/* $("#allmessage").find("div").get(0).addClass("message_item");
				 $("#allmessage").find("div").get(0).find("span").addClass("respond_btn");*/
				 
				} else if(data==0){
					alert("请先登录！");
				} else if(data==2){
					alert("评价失败！");
				}
		});
		
		
	}, false);
	
}, false);